/**
 * Created by zhulingxiao on 2017/6/7.
 */
const initialState = { loading : false, visible:false, title : '', parentid : '', link : '', icon : '', qx : '', index : '', sysid:'' };

import { MODAL_OPEN, MODAL_LOADING, MODAL_SUCCESS, MODAL_CLOSE } from '../actions/updateModal';

const modal = (state = initialState, action) => {

  switch (action.type) {

    case MODAL_OPEN:
      return Object.assign({}, state, {
        visible:true,
        title: action.title,
        parentid:action.parentid,
        link:action.link,
        icon:action.icon,
        qx:action.qx,
        index:action.index,
        sysid:action.sysid
      });

    case MODAL_LOADING:
      return Object.assign({}, state, {
        loading: true
      });

    case MODAL_SUCCESS:
      return Object.assign({}, state, {
        loading: false,
        visible: false
      });

    case MODAL_CLOSE:
      return Object.assign({}, state, {
        visible: false
      });

    default:
      return state
  }

}

export default modal
